*
*
* Compton and Philips, "Does job insecurity shape policy preferences? An experimental manipulation of labor market risk"
* Main analysis file
* 3/12/23
*
*	IMPORTANT NOTES:
*	Required user-written programs: burd, coefplot
*	
* ---------------------------------------------------------------------------
use "compton-philips-data.dta", clear
set seed 123737
set scheme burd, perm // use "findit scheme burd" if you don't have this

* Some global options:
global graphopts "mcolor(black) msymbol(T) ciopts(recast(rcap) lcolor(black))" 
global goptdem "mcolor(navy) msymbol(O) ciopts(recast(rcap) lcolor(black))"
global goptrep "mcolor(maroon) msymbol(T) ciopts(recast(rcap) lcolor(black))"
global goptind "mcolor(lavender) msymbol(S) ciopts(recast(rcap) lcolor(black))"
global boots "vce(bootstrap, rep(1000) seed(123737))"



* ------ FIGURE 1A ----------
* diff = mean(Secure T) - mean(Control) 
reg jobinsecurity secure_minus_control, $boots
est sto secure_minus_control

* diff = mean(Insecure) - mean(Control) 
reg jobinsecurity insecure_minus_control, $boots
est sto insecure_minus_control

* diff = mean(Insecure) - mean(Secure T):
reg jobinsecurity insecure_minus_secure, $boots
est sto insecure_minus_secure

su jobinsecurity  // needed for substantive effects
di  .5823633/1.837194

coefplot (secure_minus_control, $graphopts) ///
	(insecure_minus_control, $graphopts) ///
	(insecure_minus_secure, $graphopts), drop(_cons) xline(0, lcolor(black) lpattern(solid)) xtitle(Change in Job Insecurity) legend(off)
graph export "fig1a.pdf", as(pdf) replace
* ---------------------------


* --------- FIGURE 1B ---------
est clear
* diff = mean(Secure T) - mean(Control) 
reg benefit_pref secure_minus_control, $boots 
est sto secure_minus_control

* diff = mean(Insecure) - mean(Control) 
reg benefit_pref insecure_minus_control, $boots 
est sto insecure_minus_control

* diff = mean(Insecure) - mean(Secure T): 
reg benefit_pref insecure_minus_secure, $boots 
est sto insecure_minus_secure

* PLOT
coefplot (secure_minus_control, $graphopts) ///
	(insecure_minus_control, $graphopts) ///
	(insecure_minus_secure, $graphopts), drop(_cons) xline(0, lcolor(black) lpattern(solid)) xtitle(Change in UI Benefits) legend(off)
graph export "fig1b.pdf", as(pdf) replace
* ---------------------------


* --------- FIGURE 1C ---------
est clear
* diff = mean(Secure T) - mean(Control)
reg duration_pref secure_minus_control, $boots 
est sto secure_minus_control

* diff = mean(Insecure) - mean(Control) 
reg duration_pref insecure_minus_control, $boots 
est sto insecure_minus_control

* diff = mean(Insecure) - mean(Secure T): 
reg duration_pref insecure_minus_secure, $boots 
est sto insecure_minus_secure

* PLOT
coefplot (secure_minus_control, $graphopts) ///
	(insecure_minus_control, $graphopts) ///
	(insecure_minus_secure, $graphopts), drop(_cons) xline(0, lcolor(black) lpattern(solid)) xtitle(Change in Duration Eligibility) legend(off)
graph export "fig1c.pdf", as(pdf) replace
* ---------------------------


* --------- FIGURE 1D ---------
est clear
* diff = mean(Secure T) - mean(Control) 
reg strict_pref secure_minus_control, $boots 
est sto secure_minus_control

* diff = mean(Insecure) - mean(Control) 
reg strict_pref insecure_minus_control, $boots 
est sto insecure_minus_control

* diff = mean(Insecure) - mean(Secure T): 
reg strict_pref insecure_minus_secure, $boots 
est sto insecure_minus_secure

* PLOT
coefplot (secure_minus_control, $graphopts) ///
	(insecure_minus_control, $graphopts) ///
	(insecure_minus_secure, $graphopts), drop(_cons) xline(0, lcolor(black) lpattern(solid)) xtitle(Change in Restrictiveness Eligibility) legend(off)
graph export "fig1d.pdf", as(pdf) replace
* ---------------------------


* --------- FIGURE 2A ---------
est clear
* diff = mean(Secure T) - mean(Control) 
reg jobinsecurity secure_minus_control if partyid == 1, $boots // dem
est sto secure_minus_control_dem
reg jobinsecurity secure_minus_control if partyid == 2, $boots // rep
est sto secure_minus_control_rep
reg jobinsecurity secure_minus_control if partyid == 3, $boots // ind/dk
est sto secure_minus_control_ind

* diff = mean(Insecure) - mean(Control) 
reg jobinsecurity insecure_minus_control  if partyid == 1, $boots
est sto insecure_minus_control_dem
reg jobinsecurity insecure_minus_control  if partyid == 2, $boots
est sto insecure_minus_control_rep
reg jobinsecurity insecure_minus_control  if partyid == 3, $boots
est sto insecure_minus_control_ind

* diff = mean(Insecure) - mean(Secure T): 
reg jobinsecurity insecure_minus_secure  if partyid == 1, $boots 
est sto insecure_minus_secure_dem
reg jobinsecurity insecure_minus_secure  if partyid == 2, $boots 
est sto insecure_minus_secure_rep
reg jobinsecurity insecure_minus_secure  if partyid == 3, $boots 
est sto insecure_minus_secure_ind

* PLOT
coefplot (secure_minus_control_dem, $goptdem) ///
	(secure_minus_control_rep, $goptrep) ///
	(secure_minus_control_ind, $goptind) ///
	(insecure_minus_control_dem, $goptdem) ///
	(insecure_minus_control_rep, $goptrep) ///
	(insecure_minus_control_ind, $goptind) ///
	(insecure_minus_secure_dem, $goptdem) ///
	(insecure_minus_secure_rep, $goptrep) ///
	(insecure_minus_secure_ind, $goptind) ///
	, drop(_cons) xline(0, lcolor(black) lpattern(solid)) xtitle(Change in Job Insecurity) legend(off)
graph export "fig2a.pdf", as(pdf) replace
* ---------------------------




* --------- FIGURE 2B ---------
est clear
* diff = mean(Secure T) - mean(Control) 
reg benefit_pref secure_minus_control if partyid == 1, $boots 
est sto secure_minus_control_dem
reg benefit_pref secure_minus_control if partyid == 2, $boots 
est sto secure_minus_control_rep
reg benefit_pref secure_minus_control if partyid == 3, $boots 
est sto secure_minus_control_ind

* diff = mean(Insecure) - mean(Control) 
reg benefit_pref insecure_minus_control  if partyid == 1, $boots
est sto insecure_minus_control_dem
reg benefit_pref insecure_minus_control  if partyid == 2, $boots
est sto insecure_minus_control_rep
reg benefit_pref insecure_minus_control  if partyid == 3, $boots
est sto insecure_minus_control_ind

* diff = mean(Insecure) - mean(Secure T): 
reg benefit_pref insecure_minus_secure  if partyid == 1, $boots 
est sto insecure_minus_secure_dem
reg benefit_pref insecure_minus_secure  if partyid == 2, $boots 
est sto insecure_minus_secure_rep
reg benefit_pref insecure_minus_secure  if partyid == 3, $boots 
est sto insecure_minus_secure_ind

* PLOT
coefplot (secure_minus_control_dem, $goptdem) ///
	(secure_minus_control_rep, $goptrep) ///
	(secure_minus_control_ind, $goptind) ///
	(insecure_minus_control_dem, $goptdem) ///
	(insecure_minus_control_rep, $goptrep) ///
	(insecure_minus_control_ind, $goptind) ///
	(insecure_minus_secure_dem, $goptdem) ///
	(insecure_minus_secure_rep, $goptrep) ///
	(insecure_minus_secure_ind, $goptind) ///
	, drop(_cons) xline(0, lcolor(black) lpattern(solid)) xtitle(Change in UI Benefits) legend(off)
graph export "fig2b.pdf", as(pdf) replace
* ---------------------------


* --------- FIGURE 2C ---------
est clear
* diff = mean(Secure T) - mean(Control) 
reg duration_pref secure_minus_control if partyid == 1, $boots 
est sto secure_minus_control_dem
reg duration_pref secure_minus_control if partyid == 2, $boots 
est sto secure_minus_control_rep
reg duration_pref secure_minus_control if partyid == 3, $boots 
est sto secure_minus_control_ind

* diff = mean(Insecure) - mean(Control) 
reg duration_pref insecure_minus_control  if partyid == 1, $boots
est sto insecure_minus_control_dem
reg duration_pref insecure_minus_control  if partyid == 2, $boots
est sto insecure_minus_control_rep
reg duration_pref insecure_minus_control  if partyid == 3, $boots
est sto insecure_minus_control_ind

* diff = mean(Insecure) - mean(Secure T): 
reg duration_pref insecure_minus_secure  if partyid == 1, $boots 
est sto insecure_minus_secure_dem
reg duration_pref insecure_minus_secure  if partyid == 2, $boots 
est sto insecure_minus_secure_rep
reg duration_pref insecure_minus_secure  if partyid == 3, $boots 
est sto insecure_minus_secure_ind

* PLOT
coefplot (secure_minus_control_dem, $goptdem) ///
	(secure_minus_control_rep, $goptrep) ///
	(secure_minus_control_ind, $goptind) ///
	(insecure_minus_control_dem, $goptdem) ///
	(insecure_minus_control_rep, $goptrep) ///
	(insecure_minus_control_ind, $goptind) ///
	(insecure_minus_secure_dem, $goptdem) ///
	(insecure_minus_secure_rep, $goptrep) ///
	(insecure_minus_secure_ind, $goptind) ///
	, drop(_cons) xline(0, lcolor(black) lpattern(solid)) xtitle(Change in Duration Eligibility) legend(off)
graph export "fig2c.pdf", as(pdf) replace
* ---------------------------


* --------- FIGURE 2D ---------
est clear
* diff = mean(Secure T) - mean(Control) 
reg strict_pref secure_minus_control if partyid == 1, $boots 
est sto secure_minus_control_dem
reg strict_pref secure_minus_control if partyid == 2, $boots 
est sto secure_minus_control_rep
reg strict_pref secure_minus_control if partyid == 3, $boots 
est sto secure_minus_control_ind

* diff = mean(Insecure) - mean(Control) 
reg strict_pref insecure_minus_control  if partyid == 1, $boots
est sto insecure_minus_control_dem
reg strict_pref insecure_minus_control  if partyid == 2, $boots
est sto insecure_minus_control_rep
reg strict_pref insecure_minus_control  if partyid == 3, $boots
est sto insecure_minus_control_ind

* diff = mean(Insecure) - mean(Secure T): 
reg strict_pref insecure_minus_secure  if partyid == 1, $boots 
est sto insecure_minus_secure_dem
reg strict_pref insecure_minus_secure  if partyid == 2, $boots 
est sto insecure_minus_secure_rep
reg strict_pref insecure_minus_secure  if partyid == 3, $boots 
est sto insecure_minus_secure_ind

* PLOT
coefplot (secure_minus_control_dem, $goptdem) ///
	(secure_minus_control_rep, $goptrep) ///
	(secure_minus_control_ind, $goptind) ///
	(insecure_minus_control_dem, $goptdem) ///
	(insecure_minus_control_rep, $goptrep) ///
	(insecure_minus_control_ind, $goptind) ///
	(insecure_minus_secure_dem, $goptdem) ///
	(insecure_minus_secure_rep, $goptrep) ///
	(insecure_minus_secure_ind, $goptind) ///
	, drop(_cons) xline(0, lcolor(black) lpattern(solid)) xtitle(Change in Restrictiveness Eligibility) legend(off)
graph export "fig2d.pdf", as(pdf) replace
* ---------------------------



